export class BluetoothDeviceCache {
  private static instance: BluetoothDeviceCache;
  private cachedDevices: Map<string, BluetoothDevice> = new Map();

  private constructor() {}

  public static getInstance(): BluetoothDeviceCache {
    if (!BluetoothDeviceCache.instance) {
      BluetoothDeviceCache.instance = new BluetoothDeviceCache();
    }
    return BluetoothDeviceCache.instance;
  }

  public cacheDevice(deviceId: string, device: BluetoothDevice): void {
    this.cachedDevices.set(deviceId, device);
  }

  public getCachedDevice(deviceId: string): BluetoothDevice | undefined {
    return this.cachedDevices.get(deviceId);
  }

  public clearDevice(deviceId: string): void {
    this.cachedDevices.delete(deviceId);
  }

  public clearAll(): void {
    this.cachedDevices.clear();
  }
}


